unit testing swift ui

171

//    Correct result, tests succeeds
    func testAdditionCorrectResult() {
      let firstNumber = 5
      let secNumber = 9
        
      let result = firstNumber + secNumber

      // Check if the result of the addition is the expected one
      XCTAssertEqual(result, 14, "Result of addition is wrong!")
    }
//    Wrong result, tests fails
    func testAdditionWrongResult() {
      let firstNumber = 5
      let secNumber = 9
        
      let result = firstNumber + secNumber

      // Check if the result of the addition is the expected one
      XCTAssertEqual(result, 15, "Result of addition is wrong!")
    }

Comments

Submit
0 Comments